package br.com.management.mentor.app.components;

import java.io.File;

import org.apache.commons.configuration.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import br.com.management.mentor.app.Config;

@Component
public class FilesResourceLocator {

	private final String RESOUCES_FORMAT = "classpath:%s%s%s%s";
	
	private final String IMGS_FORMAT = "classpath:%s%s%s%s%s%s";
	
	@Autowired
	private Configuration config;

	public String getMenuImgURL( String imgFile ) {
		return String.format( IMGS_FORMAT , File.separator , config.getString( Config.IMGS_FOLDER.name() ) , File.separator ,  config.getString( Config.MENUS_FOLDER.name() ) , File.separator , imgFile );
	}
	
	public String getIconImgURL( String imgFile ) {
		return String.format( IMGS_FORMAT , File.separator , config.getString( Config.IMGS_FOLDER.name() ) , File.separator , config.getString( Config.ICONS_FOLDER.name() ) , File.separator , imgFile );
	}

	public String getSourceFileURL( String entitySourceFile ) {
		return String.format( RESOUCES_FORMAT , File.separator , config.getString( Config.SOURCES_FOLDER.name() ) , File.separator , entitySourceFile );
	}

}